<?php
namespace Home\Controller;
use Think\Controller;
class ApiController extends Controller {
  public function api(){
    header("Content-type: text/html; charset=utf-8");
    $wgateid = I('get.wgateid','');
    $type = I('get.type',0);

    //测试
    $wgateid = I('get.wgateid','oXQ7gt-1uSzb5dRgxNSi1EGGZQ8M');
    $type = 1;

    setcookie('shu_ces_wechat_wid',$wgateid,0,'/');
    if(empty($wxopenid)){

    }
    if($type == 0){
        $this->Redirect('Index/bind', array('wgateid'=>$wgateid), 1, '页面跳转中...');
    }
    $user = checkwgateid($wgateid);
    if($user['success'] == 0){
        //openid错误
          //  echo '1';
        $this->success('您的账号未绑定个人信息！请前往绑定',U('Index/bind/wgateid/'.$wgateid),3);die;

    }
    if($user['success'] == 2 || $user['success'] == 3){
        //  echo '2';
        $this->success('您的账号未绑定个人信息！请前往绑定',U('Index/bind/wgateid/'.$wgateid),3);die;
    }

    switch ($type) {
      case 1:
        // echo '<script>document.location = http://localhost'.U('Article/index').'</script>';
        $this->Redirect('Index/home', array('wgateid'=>$wgateid),1, '页面跳转中...');
        break;

      default:
        # code...
        break;
    }
  }
}
